#!/bin/bash
path_dir=${PWD}

source ${path_dir}/../../shrc

for files_dir in "${path_dir}"/*;do
        test="$(basename "${files_dir}")"
        if [ -d "${files_dir}" ];then
                pushd ${files_dir}
                export PROFILEARGS1="${files_dir}/in.txt"
		if [ -f "${files_dir}/test" ];then
			rm -rf ${files_dir}/test
		fi
                if [ ! -f "${files_dir}/test" ];then
			clang++ ${files_dir}/code.cpp -o ${files_dir}/test
                fi
                if [ -f "${files_dir}/test" ];then
                        { time NUM_WORKERS=4 ${files_dir}/test < ${files_dir}/in.txt; } 2>${files_dir}/time.txt
                fi
                if [ -f "${files_dir}/time.txt" ];then
                                while read line
                                do
                                        if [ -n "${line}" ];then
                                                xx=${test}','${line}
                                                echo ${xx} >> "${path_dir}/test_time_clang_samples.csv"
                                        fi
                                done <"${files_dir}/time.txt"
                        fi

                popd
        fi
done
sed -i 's/ 0m/,0m/g' "${path_dir}/test_time_clang_samples.csv"

